
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>我爱大重庆-新闻咨询-添加模块</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <style>
        .container-fluid{
            margin:10px 20px;
            border:1px solid #ccc;
            border-radius: 5px;
            margin-top: 30px;
        }
        #submit{
            margin-bottom:20px;
        }
    </style>
</head>
<body style="background-image:url(http://public.weirongm.com/DaChongQing//NewsAdmin/images/bg.png);background-position:top center;  background-attachment: fixed;">
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12 col-md-12 col-xs-12">
            <h3>分类栏目添加添加</h3>
        </div>
        <p></p>
        <table class="table" style="margin-bottom: 0;line-height: 40px !important;">
            <tr>
                <td>名称</td>
                <td>链接</td>
                <td>操作</td>
            </tr>
            <tr>
                <!--<form action="{:U('News/column')}" method="post">-->
                    <!--<td width="50%"><input type="text" name="title"> </td>-->
                    <td colspan="3"><button id="add" class="btn btn-info click">添加</button></td>
                <!--</form>-->
            </tr>
            <foreach name="column" item="column">
                <tr>
                    <td>{$column['title']}</td>
                <td>
                    http://weixin.weirongm.com/DaChongQing/News/GetCode/column/{$column['id']}
                </td>
                <td>
                    <button id="del" data-url="{:U('News/DelColumn',array('id'=>$column['id']))}" class="btn btn-danger click">删除</button>
                    &nbsp;
                    <button id="upd" data-id="{$column['id']}" class="btn btn-danger click">修改</button>
                </td>
            </foreach>
        </table>
    </div>
</div>
<div class="box-yes" style="display:none;box-shadow:0px 0px 15px #333;position: fixed;width:300px;height:150px;top:50%;left:50%;margin-top:-50px;margin-left:-150px;background:#FFF;border-radius: 5px;color:#333">
    <label style="display:block;margin-top:10px;margin-left: 0px;border-bottom: 1px solid #e5e5e5;padding-left: 10px;padding-bottom: 10px;">请输入栏目名称</label>
    <input id="key" class="form-control" style="width: 279px;margin-right:10px;margin-top:20px;margin-left:10px;" type="text" name="key">
    <button id="yes" type="button" class="btn btn-info" style="margin: 15px 11px 15px 165px;">确认</button>
    <button id="c" type="button" class="btn btn-danger">关闭</button>
</div>

<div class="box-yes1" style="display:none;box-shadow:0px 0px 15px #333;position: fixed;width:300px;height:150px;top:50%;left:50%;margin-top:-50px;margin-left:-150px;background:#FFF;border-radius: 5px;color:#333">
    <label style="display:block;margin-top:10px;margin-left: 0px;border-bottom: 1px solid #e5e5e5;padding-left: 10px;padding-bottom: 10px;">请输入你的管理密码</label>
    <input id="key1" class="form-control" style="width: 279px;margin-right:10px;margin-top:20px;margin-left:10px;" type="password" name="key">
    <button id="yes1" type="button" class="btn btn-info" style="margin: 15px 11px 15px 165px;">确认</button>
    <button id="c1" type="button" class="btn btn-danger">关闭</button>
</div>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
    $(function(){
        $("#add").click(function(){
            $(".box-yes").toggle(300);
            $("#yes").click(function(){
                var key = $("#key").val();
                $.ajax({
                    type: "post",
                    url: "{:U('News/column')}",
                    data: {title:key},
                    dataType: "text",
                    success: function(data){
//                        if(data == "1"){
////                            alert(data);
                            $(".box-yes").toggle(300);
                            window.location.href="{:U('News/column')}";
//                        }else{
//                            alert(data);
//                        }
                    }
                });
            })
        })

        $('#c1').click(function(){
            $('.box-yes1').toggle(300)
        })

        $('#c').click(function(){
            $('.box-yes').toggle(300)
        })

        $("button[id=del]").click(function(){
            $(".box-yes1").toggle(300);
            var href = $(this).attr("data-url");
            $("#yes1").click(function(){
                var key = $("#key1").val();
                $.ajax({
                    type: "post",
                    url: "{:U('NewsAdmin/IsOk')}",
                    data: {key:key},
                    dataType: "text",
                    success: function(data){
                        if(data == "1"){
//                            alert(data);
                        $(".box-yes1").toggle(300);
                        window.location.href=href;
                        }else{
                            alert(data);
                        }
                    }
                });
            })
        })

        $("button[id=upd]").click(function(){
            $(".box-yes1").toggle(300);
            var id = $(this).attr('data-id');
            $("#yes1").click(function(){
                var key = $("#key1").val();
                $.ajax({
                    type: "post",
                    url: "{:U('NewsAdmin/IsOk')}",
                    data: {key:key},
                    dataType: "text",
                    success: function(data){
                        if(data == "1"){
                            $(".box-yes1").toggle(300);
                            $(".box-yes").toggle(300);
                            $("#yes").click(function(){
                                $.ajax({
                                    type: "post",
                                    url: "{:U('News/UpdColumn')}",
                                    data: {title:$("#key").val(),id:id},
                                    dataType: "text",
                                    success: function(data){
                                        $(".box-yes").hide();
                                        window.location.href="{:U('News/column')}";
                                    }
                                });
                            })
                        }else{
                            alert(data);
                        }
                    }
                });
            })
        })
    })
//    $(function(){
//        $('#add').click(function(){
//            $(".box-yes").show();
//            $("#yes").click(function(){
//                var key = $("#key").val();
//                $.ajax({
//                    type: "post",
//                    url: "{:U('News/column')}",
//                    data: {title:key},
//                    dataType: "text",
//                    success: function(data){
//                        if(data == "1"){
//                            alert(data);
//                        }else{
//                            alert(data);
//                        }
//                    }
//                });
//            })
////        $('.click').click(function(){
////            var tpl = "<tr><td colspan='2'><input type='text' name='title'></td></tr>";
////            $('.before').html(tpl);
////        })
//    })
</script>
</body>
</html>